// info.timeLoad说明                        condition
// time    出现时间                         judge 触发的函数，返回true时会创建npc，
// pos     出现位置
// npcobj     敌人实例
// npcposition   实例化时的参数
import {red_npc} from './../main/npc'

// 创建npc实例
function create_npc(obj:red_npc,pos:any){
    obj.create_position(pos)
    return obj
}
// 关卡处理
function round_exec(time:number,round_info:any){
    if (round_info == undefined ||  round_info.timeLoad==undefined ){
        return []
    }
    let npc_list = []
    if (round_info.timeLoad.length>0 && time >= round_info.timeLoad[0].time){
        let list = round_info.timeLoad[0].npc_list
        for (let index in list) {
            npc_list.push(list[index])
        }
        round_info.timeLoad.shift()
    }
    return npc_list
}
// 关卡1信息
function round1(){
    return {
        condition:{
            
        },
        timeLoad:[
            {
                time:2000,
                npc_list:[
                    create_npc(new red_npc({speed:5,hp:5,lineAngle:180}),['40%','0%']),
                    create_npc(new red_npc({speed:3,hp:5,lineAngle:90}),['0%','50%'])
                ]
            },
            {
                time:5000,
                npc_list:[
                    create_npc(new red_npc({speed:2,hp:5,lineAngle:170}),['40%','0%']),
                    create_npc(new red_npc({speed:1,hp:5,lineAngle:-170}),['60%','0%'])
                ]
            },
        ]
    }
}

export {round_exec,round1}